package com.zhangfb95.crosschain.sdk.infra.data.api.server;

import com.zhangfb95.crosschain.infra.model.Result;
import com.zhangfb95.crosschain.protocol.rpc.RequestHeaderConstants;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcuser.RpcUserAddApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcuser.RpcUserLoginApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcuser.RpcUserUpdatePasswordApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcuser.RpcUserUpdateSecretApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.request.server.rpcuser.RpcUserUpdateUsernameApiReq;
import com.zhangfb95.crosschain.sdk.infra.model.api.response.server.rpcuser.RpcUserLoginApiRes;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;

/**
 * @author zhangfubing
 * @since 2023/10/19
 */
@HttpExchange("/rpc/user")
public interface RpcUserApi {

    @PostExchange("/add")
    Result<Void> add(@RequestBody @Validated RpcUserAddApiReq req);

    @PostExchange("/updateUsername")
    Result<Void> updateUsername(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody @Validated RpcUserUpdateUsernameApiReq req);

    @PostExchange("/updatePassword")
    Result<Void> updatePassword(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody @Validated RpcUserUpdatePasswordApiReq req);

    @PostExchange("/updateSecret")
    Result<Void> updateSecret(
            @RequestHeader(RequestHeaderConstants.USER_ID) String userId,
            @RequestHeader(RequestHeaderConstants.NONCE) String nonce,
            @RequestHeader(RequestHeaderConstants.TIMESTAMP) String timestamp,
            @RequestHeader(RequestHeaderConstants.AUTHORIZATION) String authorization,
            @RequestBody @Validated RpcUserUpdateSecretApiReq req);

    @PostExchange("/login")
    Result<RpcUserLoginApiRes> login(@RequestBody @Validated RpcUserLoginApiReq req);
}
